package base.thread_JUC2.chapter02.demo05;

import java.util.concurrent.TimeUnit;

public class Writer implements Runnable{
    private PricesInfo pricesInfo;

    public Writer (PricesInfo info) {
        this.pricesInfo = info;
    }

    @Override
    public void run() {
        for (int i = 0; i < 3; i++) {
            System.out.printf("Writer: Attempt to modify the prices.\n");
            pricesInfo.setPrices(i, i);
            System.out.printf("Writer: Prices have been modified.\n");
            try {
                TimeUnit.SECONDS.sleep(2);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
